<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<script type="text/javascript" src="/plug-in/jquery-easyui-1.5.1/datagrid-detailview.js"></script>
<title>出库管理</title>
<script>
	$(function(){
		/*列表初始化*/
		var gridParam = {
				url:"/console/com.fs.jzzn.pojo.TheLibrary/list",
				sort:"createTime",
				order:"desc",
				queryParams:{
					rightControl: true
				},
				columns : [ [ 
					{field : "billNo",width : 120,title: "出库编号"}, 
		            {field : "roadNo",width : 270,title: "订单编号"}, 
		            {field : "pRoad",width : 300,title: "订单名称"}, 
					{field : "pm",width : 120,title: "项目经理"}, 
					{field : "sender",width : 120,title: "发货人"}, 
					{field : "picking",width : 120,title: "领料人"}, 
					{field : "pickingPhone",width : 120,title: "领料人电话"}, 
					{field : "warehouseName",width : 120,title: "仓库名称"},
					{field : "outDate",width : 120,title: "出库日期"}, 
					{field : "department",width : 120,title: "关联项目部"}, 
					 {"field" : "status","width" : 80,"title" : "状态",dictionary:{'0':'暂存','1':'已出库'},formatter: function(value,row,index){
		                	return (value=='1') ? '<font color="green">已出库</font>'	: '<font color="red">暂存</font>';
		                }},
					{field : "remark",width : 150,title: "备注"},
					{field : "createTime",width : 130,title: "创建时间"},
					{field : "createrName",width : 130,title: "创建人"},
			] ],
			onLoadSuccess: function(){
				p.tooltip([ 'pRoad', 'pName', 'remark'  ]);
			},
			view: detailview,
			detailFormatter:function(index,row){
				return '<div class="details" style="padding:5px 0;min-height:200px;"></div>';
			},
			onExpandRow:function(index,row){
				var ddv = $(this).datagrid('getRowDetail',index).find('div.details');
				var detailGrid = ddv.datagrid({
					url : '/console/com.fs.jzzn.pojo.StorageItem/list',
					queryParams: {
						billNo:row.billNo,
						billNo_searchType: "eq"
					},
					title:'出库明细清单-'+ row.billNo,
					pageSize:30,
					rownumbers: true,
					pagination: true,
					singleSelect: true, 
					columns : [[
							{field : 'billNo',width : 120,title : '出库编号'}
							,{field : 'roadNo',width : 270,title : '订单编号'}
					    	,{field: 'mNo', title: '物料编码', width: 120}
						    ,{field: 'mName', title: '物料名称', width: 150} 
					    	,{field: 'mType', title: '物料规格', width: 150}
					    	,{field: 'mUnit', title: '物料单位', width: 80}
					    	,{field: 'mCount', title: '出库数量', width: 100}
				            ,{field : 'warehouseName',width : 120,	title : '仓库名称'}
					    	,{field: 'location', title: '库位', width: 100}
					]],
					onLoadSuccess:function(){
						$('#dataGrid').datagrid('fixDetailRowHeight',index);
					},
					toolbar: [
				          { iconCls: 'icon-excel', text:'出库明细导出',handler: function(){
				        	  p.down({filename:'出库清单-'+ row.billNo,local :true,grid:detailGrid});
				          }}
					]
				});
			},
			singleSelect : true
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam, gridParam));

		/*事件响应*/
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var id = $(this).attr("motion_code");p.btnOneClick($(this));
			switch (id) {
				case "01":
					p.gridAdd({ title : "出库新增", width : 600, height : 485,autoMax:true });
					break;
				case "02":
					p.gridModify({title : "出库编辑" ,width : 600, height : 485 ,autoMax:true ,onOpenBefore:function(row){
						if(row.status=='1'){
							p.tip({msg: '已出库记录无法编辑！'});  return false;
						}
					}});
					break;
				case "03":
					p.gridDelete({url:'/console/theLibrary/rewrite/delete',onOpenBefore:function(row){
						if(row.status=='1'){
							p.tip({msg: '已出库记录无法删除！'});  return false;
						}
					}});
					break;
				case "04":
					p.gridView({title : "出库查看", width : 600, height : 485,autoMax:true  });				
					break;
				case "05":
					p.gridQuery();
					break;
				case "06":
					p.gridConfirm({url:'/console/theLibrary/rewrite/confirm', title:'确认出库操作码？',msg:'出库成功！',onOpenBefore:function(row){
						if(row.status=='1'){
							p.tip({msg: '已出库！'});  return false;
						}
					}});
					break;
				case "07":
					p.down({filename:'出库管理'});
					break;
				default:
					break;
			}
		});
	});
</script>
</head>
<body  class="easyui-layout">
		<!-- 但行高度33px，多行时 33乘以行数  -->
		<div id="querybar" data-options="region:'north',split:false,border:false" style="height:33px;">
			<div class="easyui-panel" data-options="fit:true,border:false">
				<!-- 查询条件表单，根据配置进行替换  -->
				<form id="queryForm" >
				 <input type="hidden" name="className" value="com.fs.jzzn.pojo.TheLibrary" />
				 <div class="fItem">
				  	<input class="easyui-textbox" name="billNo" style="width:240px;" data-options="label:'出库编号:'" />
					<input type="hidden" name="billNo_searchType" value="like" />
				 </div>
				 <div class="fItem">
				  	<input class="easyui-textbox" name="roadNo" style="width:240px;" data-options="label:'订单编号:'" />
					<input type="hidden" name="roadNo_searchType" value="like" />
				 </div>
				 
				   <div class="fItem">
				  		<input class="easyui-datebox" name="outDate"   style="width:240px;"  data-options="label:'出库日期:'"  />
				  		<input type="hidden" name="outDate_searchType" value="like" />
				  </div>
				   <div class="fItem">
			  		<input class="easyui-combobox" name="createrId" style="width:240px;" url="/console/combobox?valueField=id&textField=nickName&modleName=user" data-options="label:'创建人:',required:false,labelWidth:60" />
			  		<input type="hidden" name="createrId_searchType" value="eq" />
			 	</div>
				</form>
			</div>
		</div>  
	
		<!-- 工具栏按钮 -->
		<div id="toolbar" class="easyui-panel" style="padding:3px;"></div>
		
		<!-- 表格 -->
		<div region="center" border="false">
			<table id="dataGrid"></table>
		</div>
</body>
</html>